<style type="text/css">
	.g_list .mytd{height:25px;}
	.title_pic{float: left;}
	.title{float:right;width:70%;}
	.text-center{font-size: 14px;}
</style>
<script type="text/javascript"> 
jQuery.fn.rowspan = function(colIdx) { //封装的一个JQuery小插件  
return this.each(function(){ 
var that; 
$('tr', this).each(function(row) { 
$('td:eq('+colIdx+')', this).filter(':visible').each(function(col) { 
if (that!=null && $(this).html() == $(that).html()) { 
rowspan = $(that).attr("rowSpan"); 
if (rowspan == undefined) { 
$(that).attr("rowSpan",1); 
rowspan = $(that).attr("rowSpan"); } 
rowspan = Number(rowspan)+1; 
$(that).attr("rowSpan",rowspan); 
$(this).hide(); 
} else { 
that = this; 
} 
}); 
}); 
}); 
}

$(function() {
	$(".g_list").rowspan(0);
	$(".g_list").rowspan(1);
	$(".g_list").rowspan(2);
	$(".g_list").rowspan(7);
}); 

</script>
             <form method="post" enctype="multipart/form-data" target="_blank" id="form-order">
                <div class="table-responsive">
                    <table class="table table-bordered">
                                <tbody>
                                <volist name="orderList" id="list" key="k">
									<?php
										if(count($list['order_list'])>=1){
									?>
                                    <tr>
                                        <td class="text-center" style="background:#e2e8ff;"><input type="checkbox" name="alluser_id[]" title="批量打印" value="{$list.user_id}"><input type="hidden" name="order_ids" value="{$list.order_ids}">&nbsp;&nbsp;店名：{$list.company}<if condition="$list['is_cod'] eq '1'"><span style="color: red">(货到付款)</span></if></td>
                                        <td class="text-center" style="background:#e2e8ff;">标识/线路：{$list.biaoshi}/{$list.biaoshi_xian}</td>
                                        
                                        <td class="text-center" style="background:#e2e8ff;">电话：{$list.mobile}</td>
                                        <td class="text-center" style="background:#e2e8ff;">地址：{$list.address}</td>
										<td class="text-center" style="background:#e2e8ff;">入库时间：{$list.shijian}</td>
                                        <td class="text-right" style="background:#e2e8ff;">
											<a href="/index.php/Admin/Order/order_print/user_id/{$list.user_id}/timegap/{$timegap}" target="_blank" data-toggle="tooltip" title="" class="btn btn-primary" data-original-title="打印配送单"><i class="fa fa-print"></i>打印配送单
                                        </td>
                                    </tr>
									
<tr>
<td class="text-center" colspan="9" style="padding:0;">
	

<table class="table table-bordered g_list" style="width:100%;">
<tr>
		<td style="width: 120px;" class="mytd">商家</td>
		<td style="width: 150px;" class="mytd">商家订单号</td>
		<td style="width: 80px;" class="mytd">包装件数</td>
		<td style="width: 220px;" class="mytd">产品名</td>
		<td style="width: 90px;" class="mytd">单价</td> 
		<td style="width: 90px;" class="mytd">数量</td>
		<td style="width: 90px;" class="mytd">小计</td>
		<td style="width: 90px;" class="mytd">优惠金额</td>
		<td style="width: 100px;" class="mytd">订单金额</td>
</tr>
<?php
	$zongje=$zongjian=0;
	?>
<volist name="list.order_list" id="lists">
	<?php
	$zongje+=($lists['order_amount']+$lists['yijia_heji']);
	$zongjian+=(float)$lists['jian_count']; 
	$points_count=0;
	$admin_note=$lists['admin_note'];
	$discount=$lists['discount']; 
	?>
	<volist name="lists.g_list" id="listss">
		<?php
		$xiaoji=sanwei((($listss['member_goods_price']+$listss['yijia'])*$listss['goods_num']),3);
		$points_count+=$xiaoji*((float)$listss['points']/100);
		
		?>
	<tr>
		<td class="mytd"><a href="/index.php/Seller/Admin/login/store_id/{$lists.store_id}" target="_blank">{$store_list[$lists[store_id]]}</a>  <span style="color:#f88e2d;">{$list[suoshu_name]}</span>
		</td>
		<td class="mytd">{$lists.order_sn}<if condition="($list[rpay]==1) AND ($list[rpay_store] == $list[store_id]) "><span style="color: red">（预付款）</span></if><br/>
		</td>
		<td class="mytd"><span style="display: none;">{$lists.order_id}</span>{$lists.jian_count}件</td>
		<td style="text-align:left;">
			<img src="{$listss.original_img}" height="50" width="50" class="title_pic" onmouseover="layer.tips('<img src={$listss.original_img} width=180>',this,{tips: [1, '#e2e8ff']});" onmouseout="layer.closeAll();">
			<div class="title">{$listss.goods_name}</div>
			<div class="title" style="color:#8e8a8a;">{$listss.spec_key_name}</div>
			</td>
		<td class="mytd">￥{:($listss['member_goods_price']+$listss['yijia'])}</td> 
		<td class="mytd">{$listss.goods_num}</td>
		<td class="mytd">￥{$xiaoji}</td>
		<td class="mytd">￥{:($lists['coupon_price'])}</td>
		<td class="mytd" style="color:red;font-size:13px">￥{:($lists['order_amount']+$lists['yijia_heji'])}</td>
	</tr>
</volist>

</volist>
<tr>
	<td class="mytd" colspan="2" style="font-weight: bold;font-size:16px;text-align: right;height: 45px;">总件数：</td>
	<td class="mytd" style="font-weight: bold;font-size:16px">{$zongjian} 件</td>
	<td class="mytd" style="text-align: left;"><b>改单：</b>
					<if condition="$admin_note eq ''">
							<span style="color:#999;">未改单</span>
					<else/>
							<span style="color:red;">改价：<b>￥{$discount}</b>，{$admin_note|htmlspecialchars_decode}</span>
					</if></td>
	<!-- <td class="text-center" colspan="1" style="color:red;"><a href="#" onclick="chukuAll('{$lists.order_id}','{$lists.jian_count}')" data-toggle="tooltip" title="" class="btn btn-info" data-original-title="一键出库">一键出库</a></td> -->
	<td class="mytd" colspan="2" style="font-weight: bold;font-size:16px;text-align: right;height: 45px;">应收总金额：</td>
	<td class="mytd" style="font-weight: bold;font-size:16px;color: red;">￥{:sanwei($zongje)}</td>
</tr>
</table>
	</td>
</tr>
<?php
}
?>
                                </volist>
                                </tbody>
                            </table>
                        </div>
                    </form>
                    <div class="row">
    <div class="navbar-form form-inline">
        全选
        <input type="checkbox" onclick="$('input[name=\'alluser_id\[\]\']').prop('checked', this.checked);">
        <button id="act_button" type="button" onclick="act_submit();" class="btn btn-primary" style="margin-left:15px;"><i class="fa"></i> 批量打印</button>
        <button id="act_button" type="button" onclick="act_chukuALl();" class="btn btn-primary" style="margin-left:15px;"><i class="fa"></i> 批量一键出库</button>
    </div>
						
                        <div class="col-sm-6 text-right">{$page}</div>
                    </div>
<script>
	$(".pagination  a").click(function(){
		var page = $(this).data('p');
		var number = $(this).data('n');
		ajax_get_table('search-form2',page,number);
	});

	$(".page_num").change(function (){
		var number = $(this).val();
		ajax_get_table('search-form2',1,number);
	})

    function get_select_user_id_str() {
        if ($('input[name="alluser_id\[\]"]:checked').length == 0)
            return false;
        var goods_arr = Array();
        $('input[name="alluser_id\[\]"]:checked').each(function () {
            goods_arr.push($(this).val());
        });
        var order_id_str = goods_arr.join(',');
        return order_id_str
    }
    //批量操作提交
    function act_submit() {
        //prompt层
        var ids = get_select_user_id_str();
        if (ids == false) {
            layer.alert('请勾选要操作的订单', {icon: 2});
            return;
        }
		window.open('/index.php/Admin/Order/order_print/user_id/'+ids+'/timegap/{:I("timegap")}');
    }

	function chukuAll(order_id,chuku_num){
		layer.confirm('您确认要一键出库吗？', {
			btn: ['确定','取消'] //按钮
		}, function(){
			layer.prompt({
				formType: 2,
				title: '请输入司机全名',
			}, function(value, index, elem){
				$.ajax({
					type:'post',
					url:"{:U('Admin/order/chuku_all')}",
					data:{order_id:order_id,driver_name:value},
					success:function(res){
						if(res){
							layer.close(index);
							let data = JSON.parse(res);
							if(data.status){
								layer.msg(data.msg, {icon:6},function(){
									ajax_get_table('search-form2',1,0)
								});
							}else{
								layer.msg(data.msg, {icon:5},function(){});
							}

						}
					}
				});
			});
		})

	}
	

    function get_select_order_id_str() {
        if ($('input[name="alluser_id\[\]"]:checked').length == 0)
            return false;
        var order_arr = Array();
        $('input[name="alluser_id\[\]"]:checked').each(function () {
            order_arr.push($(this).next().val());
        });
        var order_id_str = order_arr.join(',');
        return order_id_str
    }
	function act_chukuALl(order_id){
        var ids = get_select_order_id_str();
		console.log(33333,ids);
        if (ids == false) {
            layer.alert('请勾选要操作的订单', {icon: 2});
            return;
        }
		layer.confirm('您确认要一键出库吗？', {
			btn: ['确定','取消'] //按钮
		}, function(cindex){
			layer.close(cindex);
			layer.prompt({
				formType: 2,
				title: '请输入司机全名',
			}, function(value, index, elem){
				$.ajax({
					type:'post',
					url:"{:U('Admin/order/batch_chuku_all')}",
					data:{order_id:ids,driver_name:value},
					success:function(res){
						layer.close(index);
						if(res){
							let data = JSON.parse(res);
							if(data.status){
								layer.msg(data.msg, {icon:6},function(){
									ajax_get_table('search-form2',1,0)
								});
							}else{
								layer.msg(data.msg, {icon:5},function(){});
							}

						}
					}
				});
			});
		})

	}

</script>